package com.carleasoft.mps.cms.business.train.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.carleasoft.mps.cms.business.train.bean.entity.TrainPlanType;
import com.carleasoft.mps.cms.business.train.service.TrainPlanTypeService;
import com.carleasoft.mps.core.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 训练计划类型表 前端控制器
 * </p>
 *
 * @author fan
 * @since 2023-06-09
 */
@RestController
@RequestMapping("/trainPlanType")
public class TrainPlanTypeController {
    @Autowired
    private TrainPlanTypeService trainPlanTypeService;

    /**
     * 训练计划类型-新增
     */
    @PostMapping("trainPlanTypeAdd")
    public R add(@RequestBody TrainPlanType trainPlanType){
        return R.ok(trainPlanTypeService.add(trainPlanType));
    }
    /**
     * 训练计划类型-编辑
     */
    @PostMapping("trainPlanTypeEdit")
    public R edit(@RequestBody TrainPlanType trainPlanType){
        return R.ok(trainPlanTypeService.edit(trainPlanType));
    }
    /**
     * 训练计划类型-删除
     */
    @PostMapping("trainPlanTypeDel")
    public R delete(@RequestBody TrainPlanType trainPlanType){
        return R.ok(trainPlanTypeService.delete(trainPlanType));
    }
    /**
     * 训练计划类型-列表查询
     */
    @PostMapping("trainPlanTypeList")
    public R<List<TrainPlanType>> list(){
        return R.ok(trainPlanTypeService.list(new QueryWrapper<TrainPlanType>().orderByDesc("THE_SORT","CREATE_TIME")));
    }
}

